#ifndef __TwRenderQueueGroup_H__
#define __TwRenderQueueGroup_H__

#include "TwRenderable.h"
#include "TwCamera.h"
#include <vector>

class TwRenderQueue;

class TwRenderQueueGroup
{
public:
	typedef std::vector<TwRenderable*> RenderableList;

public:
	TwRenderQueueGroup(TwRenderQueue* parent);
	virtual ~TwRenderQueueGroup();

	void addRenderable(TwRenderable* renderable);
	void sort(TwCamera* cam);
	void clear();
	void renderObjectsList(TwCamera* camera, TimeValue t);

protected:
	struct DepthSortDescendingLess
	{
		TwCamera*	camera;

		DepthSortDescendingLess(TwCamera* cam)
			: camera(cam)
		{
		}

		bool operator()(const TwRenderable* a, const TwRenderable* b) const
		{
			// Sort by depth
			float adepth = a->getSquaredViewDepth(camera);
			float bdepth = b->getSquaredViewDepth(camera);

			// Sort DESCENDING by depth (i.e. far objects first)
			return adepth > bdepth;
		}
	};

protected:
	RenderableList mRenderableList;
};

#endif //__TwRenderQueueGroup_H__